home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE18 / TIPTRIX / COMBOFX.PAS next >
Encoding:
Pascal/Delphi Source File  |  1997-01-17  |  1.4 KB  |  71 lines

  1. unit ComboFx;
  2.  
  3. interface
  4.  
  5. uses
  6.   StdCtrls;
  7.  
  8. type
  9.   TComboBoxFix = class(TComboBox)
  10.   private
  11.     function GetSelLength: Integer;
  12.     function GetSelStart: Integer;
  13.     procedure SetSelLength(Value: Integer);
  14.     procedure SetSelStart(Value: Integer);
  15.   public
  16.     property SelLength: Integer read GetSelLength write SetSelLength;
  17.     property SelStart: Integer read GetSelStart write SetSelStart;
  18.   end;
  19.  
  20. procedure Register;
  21.  
  22. implementation
  23.  
  24. uses
  25.   Messages,
  26.   Windows,
  27.   SysUtils,
  28.   LibConst,
  29.   Classes;
  30.  
  31. type
  32.   TWordSelection = packed record
  33.     StartPos: word;
  34.     EndPos : word;
  35.   end;
  36.  
  37. function TComboBoxFix.GetSelLength: Integer;
  38. begin
  39.   Result := inherited SelLength;
  40. end;
  41.  
  42. function TComboBoxFix.GetSelStart: Integer;
  43. begin
  44.   Result := inherited SelStart;
  45. end;
  46.  
  47. procedure TComboBoxFix.SetSelStart(Value: Integer);
  48. var
  49.   Selection: TWordSelection;
  50. begin
  51.   Selection.StartPos := Value;
  52.   Selection.EndPos := Selection.StartPos + SelLength;
  53.   SendMessage(Handle, CB_SETEDITSEL, 0, Longint(Selection));
  54. end;
  55.  
  56. procedure TComboBoxFix.SetSelLength(Value: Integer);
  57. var
  58.   Selection: TWordSelection;
  59. begin
  60.   Selection.StartPos := SelStart;
  61.   Selection.EndPos := Selection.StartPos + Value;
  62.   SendMessage(Handle, CB_SETEDITSEL, 0, Longint(Selection));
  63. end;
  64.  
  65. procedure Register;
  66. begin
  67.   RegisterComponents(LoadStr(srStandard), [TComboBoxFix]);
  68. end;
  69.  
  70. end.
  71.